﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Royalsoft.Common;

namespace NJL.Web
{
    public partial class MoreServices : BasePageVisitor
    {
        private readonly NJL.BLL.NJL_COMPANY_SERVICE bllService = new BLL.NJL_COMPANY_SERVICE();
        private int PageSize = 15;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                bind();
            }

            #region SEO Load
                string[] param = { "t" };
                if (Request.QueryString["t"].ToString() == "eat")
                {
                    #region 吃
                    base.LoadPageSeoInformation("吃");
                    #endregion
                }
                else if (Request.QueryString["t"].ToString() == "live")
                {
                    #region 住
                    base.LoadPageSeoInformation("住");
                    #endregion
                }
                else if (Request.QueryString["t"].ToString() == "play")
                {
                    #region 住
                    base.LoadPageSeoInformation("玩");
                    #endregion
                }
                else if (Request.QueryString["t"].ToString() == "shop")
                {
                    #region 玩
                    base.LoadPageSeoInformation("购");
                    #endregion
                }
            #endregion
        }

        void bind()
        {
            if ("" != WEBSITE_FOCUS_CITY_CODE)
            {
                string[] param = { "t" };
                if (Request.QueryString["t"].ToString() == "eat")
                {
                    #region 吃
                    DataSet ds = bllService.GetList("NJL_COMPANY_SERVICE.TYPE_CODE='1' AND NJL_COMPANY_ID IN(select ID From NJL_COMPANY where AREA_CODE='" + WEBSITE_FOCUS_CITY_CODE + "')");

                    pager.InnerHtml = Pager.GetPageNum(ds, rptEal, PageSize, param, "/"+WEBSITE_FOCUS_CITY_NAME_PINYIN+"/gdfw/");
                    #endregion
                }
                else if (Request.QueryString["t"].ToString() == "live")
                {
                    #region 住
                    DataSet ds = bllService.GetList("NJL_COMPANY_SERVICE.TYPE_CODE='2' AND NJL_COMPANY_ID IN(select ID From NJL_COMPANY where AREA_CODE='" + WEBSITE_FOCUS_CITY_CODE + "')");

                    pager.InnerHtml = Pager.GetPageNum(ds, rptEal, PageSize, param, "/" + WEBSITE_FOCUS_CITY_NAME_PINYIN + "/gdfw/");
                    #endregion
                }
                else if (Request.QueryString["t"].ToString() == "play")
                {
                    #region 玩
                    DataSet ds = bllService.GetList("NJL_COMPANY_SERVICE.TYPE_CODE<>'1' and NJL_COMPANY_SERVICE.TYPE_CODE<>'2' and NJL_COMPANY_SERVICE.TYPE_CODE<>'20' AND NJL_COMPANY_ID IN(select ID From NJL_COMPANY where AREA_CODE='" + WEBSITE_FOCUS_CITY_CODE + "')");
                    pager.InnerHtml = Pager.GetPageNum(ds, rptEal, PageSize, param, "/" + WEBSITE_FOCUS_CITY_NAME_PINYIN + "/gdfw/");
                    #endregion
                }
                else if (Request.QueryString["t"].ToString() == "shop")
                {
                    #region 购
                    DataSet ds = bllService.GetList("NJL_COMPANY_SERVICE.TYPE_CODE='20' AND NJL_COMPANY_ID IN(select ID From NJL_COMPANY where AREA_CODE='" + WEBSITE_FOCUS_CITY_CODE + "')");
                    pager.InnerHtml = Pager.GetPageNum(ds, rptEal, PageSize, param, "/" + WEBSITE_FOCUS_CITY_NAME_PINYIN + "/gdfw/");
                    #endregion
                }
            }
            else
            {
                string[] param = { "t" };
                if (Request.QueryString["t"].ToString() == "eat")
                {
                    #region 吃
                    DataSet ds = bllService.GetList("NJL_COMPANY_SERVICE.TYPE_CODE='1' AND NJL_COMPANY_ID IN(select ID From NJL_COMPANY where NJL_SYS_BASE_ID='" + WEBSITE_CODE + "')");

                    pager.InnerHtml = Pager.GetPageNum(ds, rptEal, PageSize, param, "/gdfw/");
                    #endregion
                }
                else if (Request.QueryString["t"].ToString() == "live")
                {
                    #region 住
                    DataSet ds = bllService.GetList("NJL_COMPANY_SERVICE.TYPE_CODE='2' AND NJL_COMPANY_ID IN(select ID From NJL_COMPANY where NJL_SYS_BASE_ID='" + WEBSITE_CODE + "')");

                    pager.InnerHtml = Pager.GetPageNum(ds, rptEal, PageSize, param, "/gdfw/");
                    #endregion
                }
                else if (Request.QueryString["t"].ToString() == "play")
                {
                    #region 玩
                    DataSet ds = bllService.GetList("NJL_COMPANY_SERVICE.TYPE_CODE<>'1' and NJL_COMPANY_SERVICE.TYPE_CODE<>'2' and NJL_COMPANY_SERVICE.TYPE_CODE<>'20' AND NJL_COMPANY_ID IN(select ID From NJL_COMPANY where NJL_SYS_BASE_ID='" + WEBSITE_CODE + "')");
                    pager.InnerHtml = Pager.GetPageNum(ds, rptEal, PageSize, param, "/gdfw/");
                    #endregion
                }
                else if (Request.QueryString["t"].ToString() == "shop")
                {
                    #region 购
                    DataSet ds = bllService.GetList("NJL_COMPANY_SERVICE.TYPE_CODE='20' AND NJL_COMPANY_ID IN(select ID From NJL_COMPANY where NJL_SYS_BASE_ID='" + WEBSITE_CODE + "')");
                    pager.InnerHtml = Pager.GetPageNum(ds, rptEal, PageSize, param, "/gdfw/");
                    #endregion
                }
            }
        }

        protected void rptEal_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Literal lit = e.Item.FindControl("litStart") as Literal;
                DataRowView drv = (DataRowView)e.Item.DataItem;
                string serviceLevel = drv["SERVICE_LEVEL"].ToString();
                for (int i = 1; i <= int.Parse(serviceLevel); i++)
                {
                    lit.Text += "<img src='/Images/start.jpg' align='absmiddle' alt='" + i + "' />";
                }
            }
        }
    }
}